home *** CD-ROM | disk | FTP | other *** search
- #!/usr/sbin/perl
-
- #**************************************************************************
- #* *
- #* Copyright (c) 1996 Silicon Graphics, Inc. *
- #* All Rights Reserved *
- #* *
- #* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
- #* *
- #* The copyright notice above does not evidence any actual of intended *
- #* publication of such source code, and is an unpublished work by Silicon *
- #* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
- #* the property of Silicon Graphics, Inc. Any use, duplication or *
- #* disclosure not specifically authorized by Silicon Graphics is strictly *
- #* prohibited. *
- #* *
- #* RESTRICTED RIGHTS LEGEND: *
- #* *
- #* Use, duplication or disclosure by the Government is subject to *
- #* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
- #* Technical Data and Computer Software clause at DFARS 52.227-7013, *
- #* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
- #* Supplement. Unpublished - rights reserved under the Copyright Laws of *
- #* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
- #* Shoreline Blvd., Mountain View, CA 94039-7311 *
- #**************************************************************************
-
- # bf_menu.pl
- #
- # Script for generating buttonfly menus
-
- # Parse input
- $main_switch = shift @ARGV;
- $sub_switch = join(" ", @ARGV);
-
- # Includes
- $PATH_WEB_CGI = "/usr/demos/Demo_Interfaces/Web/cgi-scripts";
- $PATH_BUTTON_DIR = "/usr/demos/Demo_Interfaces/Buttonfly";
- require "$PATH_WEB_CGI/DEMO_includes.pl";
- require "$PATH_BUTTON_DIR/bf_const.pl";
-
- # Read Tables
- &Read_Tables;
-
- # Main switch
- if ("$main_switch" eq "$SWITCH_INFO") {
- &Run_Information;
- } elsif ("$main_switch" eq "$SWITCH_SUB_CAT") {
- &Print_Sub_Cat_Menu_Page;
- } elsif ("$main_switch" eq "$SWITCH_CAT") {
- &Print_Cat_Menu_Page;
- } elsif ("$main_switch" eq "$SWITCH_TREE_MENU") {
- &Print_Trees_Page;
- } elsif ("$main_switch" eq "$SWITCH_MENU") {
- &Print_Tree_List_Page;
- } elsif ("$main_switch" eq "$SWITCH_RELATED") {
- &Print_Related_Demo;
- } elsif ("$main_switch" eq "$SWITCH_MAN") {
- &Run_Man_Page;
- } elsif ("$main_switch" eq "$SWITCH_FIND_DEMO") {
- &Run_Find_Demo;
- } elsif ("$main_switch" eq "$SWITCH_HOW_TO") {
- &Run_How_To;
- } elsif ("$main_switch" eq "$SWITCH_PARTIAL") {
- &Print_Partial;
- } else {
- &Print_Top_Page;
- }
-
- sub Run_How_To {
- `$CMD_XCONFIRM $CMD_XCONFIRM_FLAGS $CMD_XCONFIRM_FILE "$FILE_BUTTONFLY_INFO"$CMD_NULLIFY$CMD_BACKGROUND`;
- }
-
-
- sub Print_Sub_Cat_Menu_Page {
- ($sub_cat,$cat) = split(/$TREES_DELIM/, $sub_switch);
- &Source_Table($FILE_TABLE_FEATURES, @features_categories) if ("$cat" eq "$SWITCH_FEATURES");
- &Source_Table($FILE_TABLE_MARKETS, @markets_categories) if ("$cat" eq "$SWITCH_MARKETS");
- &Source_Table($FILE_TABLE_HARDWARE, @hardware_categories) if ("$cat" eq "$SWITCH_HARDWARE");
- @demos = split(/$TABLE_SECOND_DELIM/, $demos_under{$sub_cat});
- if ($#demos > $BF_MAX_DEMOS) { # Too many demos for buttonfly to handle
- &Print_Split_Page(@demos);
- } else {
- for $demo (&alpha(@demos)) {
- ($demo_name, $demo_tree) = split(/$TREES_DELIM/, $demo);
- &Print_Demo_Button("$demo", "$demo_name");
- }
- }
- }
-
- sub Print_Split_Page {
- local(@a_demos) = &alpha(@_);
- local($done) = 0;
- foreach $i ( 0..$#a_demos ) {
- if ($i > ($BF_MAX_DEMOS-1) && ($done == 0)) {
- &Print_More_Button(@a_demos[$i..$#a_demos]);
- $done = 1 ;
- } else {
- if ($done == 0) {
- ($demo_name, $demo_tree) = split(/$TREES_DELIM/, $a_demos[$i]);
- &Print_Demo_Button("$a_demos[$i]", "$demo_name");
- }
- }
- }
- }
-
- sub Print_Partial {
- local(@demos) = split('\+', $sub_switch);
- local(@a_demos) = &alpha(@demos);
- $done = 0;
- foreach $i (0..$#a_demos) {
- if ($i > ($BF_MAX_DEMOS-1) && $done == 0) {
- &Print_More_Button(@a_demos[$i..$#a_demos]);
- $done = 1;
- } else {
- if ($done == 0) {
- ($demo_name, $demo_tree) = split(/$TREES_DELIM/, $a_demos[$i]);
- &Print_Demo_Button("$a_demos[$i]", "$demo_name");
- }
- }
- }
- }
-
- sub Print_More_Button {
- local(@demos) = @_;
- local($demo_list) = join('+', @demos);
- print "More Demos...\n";
- print "\t$FILE_BUTTONFLY_SCRIPT $SWITCH_PARTIAL $demo_list\n";
- print "\t.menu. -\n";
- print "\t.popup. $_[1] \%t\n";
- print "\t.color. $COLOR_NORM\n";
- print "\t.highcolor. $COLOR_HIGH\n";
- }
-
- sub Print_Cat_Menu_Page {
- &Read_Tables;
- &Source_Table($FILE_TABLE_FEATURES, @features_categories) if ("$sub_switch" eq "$SWITCH_FEATURES");
- &Source_Table($FILE_TABLE_MARKETS, @markets_categories) if ("$sub_switch" eq "$SWITCH_MARKETS");
- &Source_Table($FILE_TABLE_HARDWARE, @hardware_categories) if ("$sub_switch" eq "$SWITCH_HARDWARE");
- for ( &alpha(keys(%demos_under)) ) {
- &Print_Button("$SWITCH_SUB_CAT $_$TREES_DELIM$sub_switch", "$_") if ("$demos_under{$_}" ne "");
- }
- }
-
- sub Run_Information {
- ($demo_name, $demo_tree) = split(/$TREES_DELIM/, $sub_switch);
- $tree_path = &Tree_Path_From_Name("$demo_tree");
- &Parse_Demo_Info("$tree_path/$demo_name/$DEMOSRC_INDEX");
- open(TMP, ">$FILE_INFO_TMP");
- print TMP "$demo_info{'DESCRIPTION'}\n";
- close(TMP);
- `$CMD_FMT -60 $FILE_INFO_TMP>$FILE_INFO_TMP2`;
- `$CMD_XCONFIRM $CMD_XCONFIRM_FILE "$FILE_INFO_TMP2" $CMD_XCONFIRM_FLAGS`;
- `$CMD_RM $FILE_INFO_TMP <<y`;
- `$CMD_RM $FILE_INFO_TMP2 <<y`;
- }
-
- sub Run_Man_Page {
- ($demo_name, $demo_tree) = split(/$TREES_DELIM/, $sub_switch);
- &Display_Man_Page("$demo_name");
- }
-
- sub Print_Tree_List_Page {
- local($demo_name, $demo_tree, @demos);
- @demos = &Demos_In_Tree("$sub_switch");
- if ($#demos > $BF_MAX_DEMOS) {
- foreach $i (0..$#demos) {
- local($demo_str) = "$demos[$i]$TREES_DELIM$sub_switch";
- $demos[$i] = $demo_str;
- }
- &Print_Split_Page(@demos);
- } else {
- for (@demos) {
- &Print_Demo_Button("$_$TREES_DELIM$sub_switch", "$_");
- }
- }
- }
-
- sub Get_User_Input {
- local($user_input, $buf);
- undef $user_input;
- undef $buf;
- #system("$CMD_LAUNCH -h echo -m \"Demo Name:\" > $FILE_SEARCH_TMP");
- open(FILE, "$CMD_LAUNCH -h echo -m \"Demo Name:\"|");
- #open(FILE, "$FILE_SEARCH_TMP");
- while(<FILE>) {
- #print "$_\n";
- $user_input .= $_;
- }
- close(FILE);
- `$CMD_RM $FILE_SEARCH_TMP`;
- chop $user_input;
- return($user_input);
- }
-
- sub Run_Find_Demo {
-
- ## Bob Penrod 02 December 1997
- ## fork this process so we don't block the parent buttonfly proc
- ## if fork returns a non-zero value, we're the parent, so quit.
- if ( fork() != 0 ) { return; }
-
- $user_input = &Get_User_Input;
- @results = &Find_Demos_By_Title("$user_input");
- if (@results) {
- ## Bob Penrod 02 December 1997
- ## Open a pipe to a new buttonfly proc and write a menu to it
- open (BF_IN, "| $PATH_BUTTON_DIR/buttonfly -");
- print BF_IN "\t.backcolor. .45 .45 .69\n";
- local ($std_out) = *STDOUT; ## Save ref to orig STDOUT
- *STDOUT = BF_IN; ## Redirect STDOUT to buttonfly
- for $demo (@results) {
- ($demo_name, $demo_tree) = split(/$HTTP_TREES_DELIM/, $demo);
- $demo_tree =~ s/\+/ /g;
- &Print_Demo_Button("$demo_name$TREES_DELIM$demo_tree", "$demo_name");
- }
- close(BF_IN); ## close buttonfly pipe
- *STDOUT = $std_out; ## Restore original STDOUT
- } else {
- open(CMD, "$CMD_XCONFIRM -header \"$TITLE_FIND_DEMO\" -B OK -b Search -icon info -t \"Demo not found: $user_input\"|");
- read(CMD, $answer, 100);
- close(CMD);
- chop $answer;
- &Run_Find_Demo if ( "$answer" eq "Search" );
- }
- }
-
- sub Print_Button {
- print "$_[1]\n";
- print "\t$FILE_BUTTONFLY_SCRIPT $_[0]\n";
- print "\t.menu. -\n";
- print "\t.popup. $_[1] \%t\n";
- print "\t.color. $COLOR_NORM\n";
- print "\t.highcolor. $COLOR_HIGH\n";
- }
-
- sub Print_Demo_Button {
- ($demo_name, $demo_tree) = split(/$TREES_DELIM/, $_[0]);
- $demo_path = &Tree_Path_From_Name("$demo_tree");
- chdir("$demo_path");
- opendir(DIR, "$demo_path/$demo_name");
- @menus = grep(/\.m_.*/, readdir(DIR));
- closedir(DIR);
- if (@menus) {
- print "$_[1]\n";
- print "\t$FILE_BUTTONFLY_SCRIPT $SWITCH_RELATED $_[0]\n";
- print "\t.menu. -\n";
- print "\t.popup. $_[1] \%t\n";
- print "\t.color. $COLOR_NORM\n";
- print "\t.highcolor. $COLOR_HIGH\n";
- } else {
- print "$_[1]\n";
- print "\t.cd. $demo_path/$demo_name\n";
- print "\t$demo_path/$demo_name/$DEMOSRC_RUN\n";
- print "\t.popup. $_[1] \%t\n";
- print "\t.popup. Information\n";
- print "\t$FILE_BUTTONFLY_SCRIPT $SWITCH_INFO $_[0]\n";
- print "\t.popup. Manual\n";
- print "\t$FILE_BUTTONFLY_SCRIPT $SWITCH_MAN $_[0]\n";
- print "\t.color. $COLOR_NORM_END\n";
- print "\t.highcolor. $COLOR_HIGH_END\n";
- }
- }
-
-
- sub Print_Related_Demo {
- ($demo_name, $demo_tree) = split(/$TREES_DELIM/, $sub_switch);
- $demo_path = &Tree_Path_From_Name("$demo_tree");
- chdir("$demo_path");
- opendir(DIR, "$demo_path/$demo_name");
- @menus = grep(/\.m_.*/, readdir(DIR));
- closedir(DIR);
- print "$demo_name\n";
- print "\t.cd. $demo_path/$demo_name\n";
- print "\t$demo_path/$demo_name/$DEMOSRC_RUN\n";
- print "\t.popup. $demo_name \%t\n";
- print "\t.popup. Information\n";
- print "\t$FILE_BUTTONFLY_SCRIPT $SWITCH_INFO $sub_switch\n";
- print "\t.popup. Manual\n";
- print "\t$FILE_BUTTONFLY_SCRIPT $SWITCH_MAN $sub_switch\n";
- print "\t.color. $COLOR_NORM_END\n";
- print "\t.highcolor. $COLOR_HIGH_END\n";
- foreach $menu (@menus) {
- open(MENU, "$demo_path/$demo_name/$menu");
- while (<MENU>) {
- print "$_";
- }
- close(MENU);
- }
- }
-
- sub Print_Trees_Page {
- local(@trees);
- @trees = &List_Tree_Names;
- for (@trees) {
- &Print_Button("$SWITCH_MENU $_", "$_");
- }
- }
-
- sub Print_Add_Ons {
- local(@allfiles, @alldirs, @dirs);
- chdir("$PATH_DEMO_DIR");
- opendir(DIR, "$PATH_ADDONS_DIR");
- @allfiles = readdir(DIR);
- closedir(DIR);
- for (@allfiles) {
- push(@alldirs, $_) if chdir("$PATH_ADDONS_DIR/$_");
- }
- @dirs = grep(!/^\.\.?$/, @alldirs);
- for (@dirs) {
- print "$_\n";
- print "\t.cd. $PATH_ADDONS_DIR/$_\n";
- print "\tcat ./.m*\n";
- print "\t.menu. -\n";
- print "\t.popup. $_ %t\n";
- print "\t.color. $COLOR_NORM\n";
- print "\t.highcolor. $COLOR_HIGH\n";
- }
- }
-
- sub Print_Top_Page {
- &Print_Button("$SWITCH_CAT $SWITCH_FEATURES", "$TITLE_FEATURES");
- &Print_Button("$SWITCH_CAT $SWITCH_MARKETS", "$TITLE_MARKETS");
- &Print_Button("$SWITCH_TREE_MENU", "$TITLE_TREE_MENU");
- &Print_Button("$SWITCH_FIND_DEMO", "$TITLE_FIND_DEMO");
- &Print_Button("$SWITCH_CAT $SWITCH_HARDWARE", "$TITLE_HARDWARE");
- &Print_Add_Ons;
- }
-
-
-